home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group02b.txt
/
000167_icon-group-sender_Tue Dec 24 12:31:58 2002.msg
< prev
next >
Wrap
Internet Message Format
|
2003-01-02
|
2KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id gBOJVv206539
for icon-group-addresses; Tue, 24 Dec 2002 12:31:57 -0700 (MST)
Message-Id: <200212241931.gBOJVv206539@baskerville.CS.Arizona.EDU>
From: ernobe <ernobe@msn.com>
X-Newsgroups: comp.lang.icon
Subject: Re: Scanning question
Date: Tue, 24 Dec 2002 07:12:01 +0200
X-Newsreader: MicroPlanet Gravity v2.50
To: icon-group@cs.arizona.edu
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
In article <au88ah$5chfl$1@ID-79573.news.dfncis.de>, ahamm@mail.com says...
> ernobe wrote:
> > Can a scanning operation be done within a conjunction? It seems that
> > backtracking into it does not produce the next result but begins the
> > scanning over again. And if the '?' scanning expression is put out
> > of the conjunction, the part that is left in it sets the position
> > back to where it was before scanning when the other expressions in
> > the conjunction are evaluated.
>
> A sample of code please? Conjunction does backtrack so probably you are
> doing something to break the scan.
>
>
>
I wanted to scan thru several lines in a file searching for strings that have
been scanned out of another file. So if an operation on a specific line fails
to produce results, I need to go to the next line while keeping count of the
number of strings that have been scanned ( I need to match the string itself
and find its position in the file ). I had something like
var := 1 # number of string
every
line := read() do (
line ? while tab( upto( &letters ) ) do
str := tab( many( &letters ) ) \ 1,
count +:= 1,
if count = var then write( file, str ),
count := 0 )
The problem is that if a line has no matches, I need to continue with another
line without setting the count back to zero. 'Every' is not a loop structure
so I can't put a 'next' in there before the count is set back to zero. I
realize now that the scanning expression itself was not the problem after all.
I need to re-organize my program. By the way, if the 'then' clause fails in
the conjunction, does the 'if' clause itself fail? If one backtracks into a
conjunction, does the whole thing resume, or just the final expression?
--
my esoteric links:
http://www.costarricense.cr/pagina/ernobe/